#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <list>
#include <vector>
using namespace std;

void test_list1()
{
	list<int> lt1;
	list<int> lt2(5, 4);
	list<int> lt3(lt2.begin(), lt2.end());

	vector<int> v(4, 7);
	list<int> lt4(v.begin() + 1, v.end() - 1);
	list<int> lt5(lt4);
}

void test_list2()
{
	list<int> lt1;
	list<int> lt2(5, 4);
	lt1 = lt2;
}

void test_list3()
{
	int a[10] = { 1, 2, 3, 4, 5 };
	list<int> lt1(a, a+ 5);

	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;

	list<int>::iterator it = lt1.begin();
	while (it != lt1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	list<int>::reverse_iterator it1 = lt1.rbegin();
	while (it1 != lt1.rend())
	{
		cout << *it1 << " ";
		++it1;
	}
	cout << endl;
}

void test_list4()
{
	int a[10] = { 1, 2, 3, 4, 5 };
	list<int> lt1(a, a + 5);
	list<int>lt2;
	cout << lt1.empty() << endl;
	cout << lt1.size() << endl;

	cout << lt2.empty() << endl;
	cout << lt2.size() << endl;
}
void test_list5()
{
	int a[10] = { 1, 2, 3, 4, 5 };
	list<int> lt1(a, a + 5);
	list<int>lt2(3, 5);
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;
	lt2.assign(lt1.begin(), lt1.end());
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;

}

void test_list6()
{
	
	list<int> lt1;
	lt1.push_front(1);
	lt1.push_front(2);
	lt1.push_front(3);
	lt1.push_front(4);
	lt1.push_front(5);
	
	lt1.pop_front();

	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
	lt1.push_back(6);
	lt1.push_back(7);
	
	lt1.pop_back();
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
}

void test_list7()
{

	int a[10] = { 1, 2, 3, 4, 5 };
	list<int> lt1(a, a + 5);
	list<int>::iterator it = lt1.begin();
	int ret = 1;
	while (ret--)
	{
		it++;
	}
	lt1.insert(it, 8);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;

	list<int> lt2(a, a + 5);
	list<int>::iterator pos = lt2.begin();
	lt2.erase(pos);
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;
}

void test_list8()
{
	int a[10] = { 1, 2, 3, 4, 5 };
	list<int> lt1(a, a + 5);
	list<int> lt2(5, 1);
	lt1.swap(lt2);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;
	lt1.clear();
}

void test_list9()
{
	int a[10] = { 1, 2, 3, 4, 5 };
	/*list<int> lt1(a, a + 5);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
	lt1.resize(10);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;*/
	list<int> lt2(a, a + 5);
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;
	lt2.reverse();
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;
}
void test_list10()
{
	int a[10] = { 1, 2, 3, 4, 5 };
	list<int> lt1(a, a + 5);
	list<int> lt2;
	lt2.push_back(3);
	lt2.push_back(1);
	lt2.push_back(4);
	lt2.push_back(5);

	lt1.sort();
	lt2.sort();
	lt2.merge(lt1);
	cout << lt1.size();
	cout << endl;
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
}

void test_list11()
{
	int a[10] = { 1, 1, 3, 4, 5, 5 };
	list<int> lt1(a, a + 6);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
	lt1.unique();
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
	lt1.remove(1);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
}
void test_list12()
{
	int a[10] = { 1, 1, 3, 4, 5, 5 };
	list<int> lt1(a, a + 6);
	list<int> lt2;
	lt2.push_back(7);
	lt2.push_back(12);
	lt2.push_back(1);
	lt2.push_back(3);
	/*lt1.splice(lt1.begin(), lt2);
	cout << lt2.size() << endl;
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;*/
	lt1.splice(lt1.begin(), lt2, lt2.begin());
	cout << lt2.size() << endl;
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
}
void test_list13()
{
	int a[10] = { 1, 1, 3, 4, 5, 5 };
	list<int> lt1(a, a + 6);
	list<int> lt2;
	lt2.push_back(7);
	lt2.push_back(12);
	lt2.push_back(1);
	lt2.push_back(3);
	lt1.splice(lt1.begin(), lt2, lt2.begin(), lt2.end());
	cout << lt2.size() << endl;
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
}
int main()
{
	test_list13();
	return 0;
}